package edu.xjtu.jih.Star;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StarDao {

    @Insert("insert into user_star(u_id,item_id,star) values(#{u_id},#{item_id},#{star})")
    void star(StarDto dto);

    @Update("delete from user_star where item_id=#{item_id} and u_id=#{u_id}")
    void cancelStar(StarDto dto);

    @Select("select items.* from user_star,items where user_star.u_id=#{u_id} and user_star.item_id=items.item_id")
    List<ItemDto> getAllStarItem(int u_id);

    @Select("select items.* from items,user_item where user_item.u_id=#{u_id} and user_item.item_id = items.item_id")
    List<ItemDto> getAllPublishItem(int u_id);

    @Select("select star from user_star where item_id=#{item_id} and u_id=#{u_id}")
    Integer getStarByItemId(StarDto dto);
}
